package com.web.dao;

import com.web.entity.MskSaleOrder;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * @author FDjavaone
 */
public interface MskSaleOrderMapper {


    @Delete({
            "delete from t_msk_sale_order",
            " where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
            "insert into t_msk_sale_order (m_id, name,",
            " phone, num, deal_time, ",
            " deal_price, deal_amt, ",
            " poundage_rate, poundage, ",
            " status, is_first, ",
            " create_time, modify_time)",
            " values (#{mId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
            " #{phone,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER}, #{dealTime,jdbcType=TIMESTAMP}, ",
            " #{dealPrice,jdbcType=DECIMAL}, #{dealAmt,jdbcType=DECIMAL}, ",
            " #{poundageRate,jdbcType=DOUBLE}, #{poundage,jdbcType=DECIMAL}, ",
            " #{status,jdbcType=INTEGER}, #{isFirst,jdbcType=INTEGER}, ",
            " #{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
    int insert(MskSaleOrder record);

    @InsertProvider(type = MskSaleOrderSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Long.class)
    int insertSelective(MskSaleOrder record);


    @Select({
            "select",
            " id, m_id, name, phone, num, deal_time, deal_price, deal_amt, poundage_rate, ",
            " poundage, status, is_first, create_time, modify_time",
            " from t_msk_sale_order",
            " where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "m_id", property = "mId", jdbcType = JdbcType.BIGINT),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR),
            @Result(column = "num", property = "num", jdbcType = JdbcType.INTEGER),
            @Result(column = "deal_time", property = "dealTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "deal_price", property = "dealPrice", jdbcType = JdbcType.DECIMAL),
            @Result(column = "deal_amt", property = "dealAmt", jdbcType = JdbcType.DECIMAL),
            @Result(column = "poundage_rate", property = "poundageRate", jdbcType = JdbcType.DOUBLE),
            @Result(column = "poundage", property = "poundage", jdbcType = JdbcType.DECIMAL),
            @Result(column = "status", property = "status", jdbcType = JdbcType.INTEGER),
            @Result(column = "is_first", property = "isFirst", jdbcType = JdbcType.INTEGER),
            @Result(column = "create_time", property = "createTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modify_time", property = "modifyTime", jdbcType = JdbcType.TIMESTAMP)
    })
    MskSaleOrder selectByPrimaryKey(Long id);


    @UpdateProvider(type = MskSaleOrderSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(MskSaleOrder record);

    @Update({
            "update t_msk_sale_order",
            " set m_id = #{mId,jdbcType=BIGINT},",
            " name = #{name,jdbcType=VARCHAR},",
            " phone = #{phone,jdbcType=VARCHAR},",
            " num = #{num,jdbcType=INTEGER},",
            " deal_time = #{dealTime,jdbcType=TIMESTAMP},",
            " deal_price = #{dealPrice,jdbcType=DECIMAL},",
            " deal_amt = #{dealAmt,jdbcType=DECIMAL},",
            " poundage_rate = #{poundageRate,jdbcType=DOUBLE},",
            " poundage = #{poundage,jdbcType=DECIMAL},",
            " status = #{status,jdbcType=INTEGER},",
            " is_first = #{isFirst,jdbcType=INTEGER},",
            " create_time = #{createTime,jdbcType=TIMESTAMP},",
            " modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
            " where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(MskSaleOrder record);
}